import { request } from '../utils/request.js'
import store from '../store'
import { Toast } from '../utils/tools.js'

//获取资讯详情
export async function GetNewsInfo(params) {
	console.log('params===>', params)
	try {
		let { success, data, msg } = await request({
			url: '/News/GetNewsInfo',
			method: "post",
			mask: false,
			params
		})
		return { data };
	} catch (e) {
		console.log(e)
		return {}
	}
}

//获取资讯分页
export async function GetNewsPage(params) {
	try {
		let { success, totalCount, msg, list, pageCount } = await request({
			url: '/News/GetNewsPage',
			method: "post",
			mask: false,
			params
		})
		if (success) {
			list.forEach(item => {
				item.content = item.content.replace(/<[^>]*>/g, "")
				item.picurl = item.picurl.split(',')
				item.pic = item.picurl[0]
			})
		}
		return { list, success, msg, pageCount };
	} catch (e) {
		console.log(e)
		return []
	}
}